//
//  Appearance.swift
//  SHMath
//
//  Created by zhuxuhong on 2017/9/27.
//  Copyright © 2017年 北大方正电子. All rights reserved.
//

import UIKit

enum Appearance {
	case `default`
	case red
	
	public func apply(){
		configureButton()
		configureProgressView()
		configureNavigationBar()
		configureTabBar()
		configureToolBar()
		configureLabel()
		configureSwitch()
	}
	
	private func configureNavigationBar(){
		let appearance = UINavigationBar.appearance()
		appearance.isTranslucent = false
		appearance.barTintColor = (self == .default) ? .appGreen : .appRed
		appearance.tintColor = .white
		appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
		appearance.backIndicatorImage = UIImage.named("nav_back")
		appearance.backIndicatorTransitionMaskImage = UIImage.named("nav_back")
	}
	
	private func configureTabBar(){
		let appearance = UITabBar.appearance()
		appearance.isTranslucent = false
		appearance.tintColor = .appGreen
	}
	
	private func configureToolBar(){
		let appearance = UIToolbar.appearance()
		appearance.isTranslucent = false
		appearance.tintColor = .appGreen
	}
	
	private func configureProgressView(){
		let appearance = UIProgressView.appearance()
		appearance.trackTintColor = .border
		appearance.progressTintColor = .appGreen
	}
	
	private func configureButton(){
		if #available(iOS 9.0, *) {
			let appearance = UIButton.appearance(whenContainedInInstancesOf: [UITableViewCell.self])
			appearance.tintColor = .appGreen
		} else {
			
		}
	}
	
	private func configureLabel(){
	}
	
	private func configureSwitch(){
		let appearance = UISwitch.appearance()
		appearance.onTintColor = .appGreen
	}
}



